#!/bin/bash

#------------------Create Data------------------
echo "
# loop names	Baseline	Split		Color		Block	
Accu 		21331.23	14281.56	21401.63	16660.41 
Edegcon     	34700.64 	22697.02	23365.67	23280.62	
Vflux		45232.09	38213.48	88531.3		31658.32
Iflux		12234.96	5416.51		9693.73		8363.19
Wfflux		978.04		834.60		1029.66		544.09
Sumwalls	228.34		117.38		211.06		94.81
"> data1




#--------------------------Plot Data----------------------------

gnuplot <<END
reset
set grid xtics ytics mxtics mytics 
set term epslatex color 
set size 1,0.85


#set format "$%g$"
#set format xy "$%g$"

set xlabel " " 
set ylabel "Runtime (mili-seconds)"3,2

#set xrange [0:1024]
#set yrange [1:1000]

set style line 1 lt -1 lw 0.3
set key width -2.7
set key box linestyle 1 outside top

set key horiz
#set log x 2
set log y 2
set border lw 2

set output "./Fig.tex"

set auto x
set style data histogram



set style histogram cluster gap 2 
set style fill solid 1 border -1 
set boxwidth  1.0

set xtic rotate by 0
#set boxwidth 20 relative

plot 'data1' using 2:xtic(1) linecolor rgb '#880000' ti "Baseline",\
     		      '' u 3 linecolor rgb '#0000CC' ti "Split",\
  		      '' u 4 fill pattern 12 linecolor rgb '#000000' ti "Color",\
   		      '' u 5 fill pattern 1 linecolor rgb '#006600' ti "Block";
END

#
#,\
#   		      '' u 6 fill pattern 2 linecolor rgb '#800080' ti "Split+Color",\
#		      '' u 7 fill pattern 3 linecolor rgb '#800080' ti "Split+BLock",\
#		      '' u 8 fill pattern 4 linecolor rgb '#800080' ti "Split+Block+Color";

#-----------------------------------------

epstopdf Fig.eps

#-----------------------------------------
echo " \documentclass{article}
\usepackage{graphics}
\usepackage{nopageno}
%\usepackage{mathpazo}
\usepackage{txfonts}
\usepackage[usenames]{color}
	
\begin{document}
	
\begin{center}
  \normalsize{
  \input{./Fig.tex}}
\end{center}
	
\end{document}" > Figure.tex
#-----------------------------------------

pdflatex Figure.tex
pdfcrop Figure.pdf

mv Figure-crop.pdf alloptimisations.pdf

rm -f data* Figure.tex Figure.pdf Figure.log Figure.aux Figure.log Fig.eps Fig.tex Fig.pdf *~
evince alloptimisations.pdf &
